package cn.ekuma.epos.datalogic.define.dao;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.symmetricds.AppConfig;
import cn.ekuma.epos.symmetricds.bean.NodeGroup;

public class NodeGroupDAO extends BaseDAO<NodeGroup> {

	public NodeGroupDAO(I_Session s) {
		super(s);
	}

	@Override
	public NodeGroup readValues(DataRead dr,NodeGroup obj) throws BasicException {
		if(obj==null)
			obj=new NodeGroup();
		obj.setNodeGroupId(dr.getString(1));
		obj.setDescription(dr.getString(2));
		return obj;
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition(s,
				AppConfig.getAppProperty(AppConfig.TABLE_PREFIX)+"_"+"node_group",
                new Field[]{
                   new Field("node_group_id",Datas.STRING, Formats.STRING),
                   new Field("description",Datas.STRING, Formats.STRING)
                 },
                new int[]{0}
                );
	}
	
	/**
	 * <table name="node_group" description="A category of Nodes that synchronizes data with one or more NodeGroups. A common use of NodeGroup is to describe a level in a hierarchy of data synchronization.">
        <column name="node_group_id" type="VARCHAR" size="50" required="true" primaryKey="true" description="Unique identifier for a node group, usually named something meaningful, like 'store' or 'warehouse'."/>
        <column name="description" type="VARCHAR" size="255" description="A description of this node group."/>
    </table>
	 */

	@Override
	public void writeInsertValues(DataWrite dp, NodeGroup obj)
			throws BasicException {
		dp.setString(1,obj.getNodeGroupId());
		dp.setString(2,obj.getDescription());

	}

	@Override
	public Class getSuportClass() {
		return NodeGroup.class;
	}

}
